//
//  BVLoginoutShoppingCart.m
//  BuyVegetable
//
//  Created by yushanchang on 16/10/15.
//  Copyright © 2016年 com.yinding. All rights reserved.
//  未登录视图

#import "BVLoginoutShoppingCarts.h"
#import "UIView+Extension.h"

@interface BVLoginoutShoppingCarts ()

@end

@implementation BVLoginoutShoppingCarts

- (instancetype)initWithFrame:(CGRect)frame {

    if (self = [super initWithFrame:frame]) {
        [self setBackgroundColor:[UIColor BVBackgroundLightGrayColor]];
        [self addLogoutView];
    }
    return self;
}

- (void)addLogoutView {
    
    UIImageView *header = [[UIImageView alloc] init];
    [header setFrame:CGRectMake((ScreenW - 200)/2, 50, 200, 200)];
    [header setImage:[UIImage imageNamed:@"gouwucheweidenglu"]];
    [self addSubview:header];
    
    UILabel *titleLabel = [[UILabel alloc] init];
    [titleLabel setX:header.x];
    [titleLabel setY:CGRectGetMaxY(header.frame) + 10];
    [titleLabel setWidth:200];
    [titleLabel setHeight:40];
    [titleLabel setFont:[UIFont systemFontOfSize:20]];
    [titleLabel setTextColor:[UIColor BVTextLightGrayColor]];
    [titleLabel setTextAlignment:NSTextAlignmentCenter];
    [titleLabel setText:@"您还没有登录哦～"];
    [self addSubview:titleLabel];
    
    UIButton *loginButton = [[UIButton alloc] init];
    [loginButton setTitle:@"登录" forState:UIControlStateNormal];
    [loginButton setBackgroundColor:[UIColor BVBaseOrangeColor]];
    [loginButton setTag:666];
    [loginButton setX:20];
    [loginButton setY:CGRectGetMaxY(titleLabel.frame) + 20];
    [loginButton setWidth:ScreenW - 40];
    [loginButton setHeight:40];
    [loginButton addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    [loginButton.layer setMasksToBounds:YES];
    [loginButton.layer setCornerRadius:3];
    [self addSubview:loginButton];

}

#pragma mark -
#pragma mark - 购物车为空或未登录按钮点击事件
- (void)buttonClick:(UIButton *)button {
    if (self.logoutBlock) {
        self.logoutBlock();
    }
}

@end
